<!--
 * @FilePath     : /study_code/jquery/api-queue2.html
 * @Description  : .dequeue() 终止自定义队列
 * @Date         : 2025-04-17 11:01:15
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-17 11:04:56
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <style>
      div {
        margin: 3px;
        width: 40px;
        height: 40px;
        position: absolute;
        left: 0px;
        top: 30px;
        background: green;
        display: none;
      }
      div.newcolor {
        background: blue;
      }
    </style>
  </head>
  <body>
    Click here...
    <div></div>

    <script src="/jquery/dist/jquery.min.js"></script>
    <script>
      $(document.body).click(function () {
        $('div').show('slow')
        $('div').animate({ left: '+=200' }, 2000)
        $('div').queue(function () {
          $(this).addClass('newcolor')
          $(this).dequeue() // 调用后函数继续执行队列 （若不调用，队列就停在这里）
        })
        $('div').animate({ left: '-=200' }, 500)
        $('div').queue(function () {
          $(this).removeClass('newcolor')
          $(this).dequeue()
        })
        $('div').slideUp()
      })
    </script>
  </body>
</html>
